package com.kexin.service;

import com.kexin.mappers.data1.Test1Mapper;
import com.kexin.mappers.data2.TVoucherMapper;
import com.kexin.pojo.TVoucher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class TVoucherService {
    @Autowired
    private Test1Mapper test1Mapper;
    @Autowired
    private TVoucherMapper test2Mapper;
    @Autowired
    private TVoucherMapper tVoucherMapper;

    public Integer add(TVoucher tVoucher){
        tVoucherMapper.insertSelective(tVoucher);
        Example example = new Example(TVoucher.class);
        example.setOrderByClause("fvoucherid DESC");
        List<TVoucher> tVouchers = tVoucherMapper.selectByExample(example);
        return tVouchers.get(0).getFvoucherid();
    }



    public Integer getVoucherNumMax() {

        return tVoucherMapper.getVoucherNumMax().getFnumber();


    }

    public void updateVoucher(TVoucher t) {
        tVoucherMapper.updateByPrimaryKeySelective(t);
    }

    public Integer getFSerialNumMax() {
        return tVoucherMapper.selectFSerialNumMax().getFserialnum();
    }

//    public List<Test> selectAll11() {
//        return test1Mapper.selectAll1();
//
//    }
//    public List<TItem> selectAll12() {
//        return test2Mapper.selectAll1();
//
//    }
//    public List<TVoucher> selectAll1(){
//       return tVoucherMapper.selectAll();
//    }
}
